package cmpe226.spring2011.project1;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class RecordDTO {
    private Date date;
    private double open, high, low, close, adjclose;
    private int volume;

    public RecordDTO(String[] fields) {
        try {
            date     = toDate(fields[0]);
            open     = Double.parseDouble(fields[1]);
            high     = Double.parseDouble(fields[2]);
            low      = Double.parseDouble(fields[3]);
            close    = Double.parseDouble(fields[4]);
            volume   = Integer.parseInt(fields[5]);
            adjclose = Double.parseDouble(fields[6]);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    public Date getDate() {
        return date;
    }

    public double getOpen() {
        return open;
    }

    public double getHigh() {
        return high;
    }
    
    public double getLow() {
        return low;
    }
    
    public double getClose() {
        return close;
    }
    
    public int getVolume() {
        return volume;
    }
    
    public double getAdjClose() {
        return adjclose;
    }

    private Date toDate(String dateString) throws ParseException {
        return (new SimpleDateFormat("yyyy-MM-dd")).parse(dateString);
    }

}
